package com.fbs.wowo.chat.mapper;

import com.fbs.wowo.chat.entity.CrewMember;
import org.apache.ibatis.jdbc.SQL;

public class CrewMemberSqlProvider {

    public String insertSelective(CrewMember record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("crew_member");
        
        if (record.getUid() != null) {
            sql.VALUES("uid", "#{uid,jdbcType=VARCHAR}");
        }
        
        if (record.getCid() != null) {
            sql.VALUES("cid", "#{cid,jdbcType=VARCHAR}");
        }
        
        if (record.getNickname() != null) {
            sql.VALUES("nickname", "#{nickname,jdbcType=VARCHAR}");
        }
        
        if (record.getValid() != null) {
            sql.VALUES("valid", "#{valid,jdbcType=TINYINT}");
        }
        
        if (record.getShield() != null) {
            sql.VALUES("shield", "#{shield,jdbcType=TINYINT}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(CrewMember record) {
        SQL sql = new SQL();
        sql.UPDATE("crew_member");
        
        if (record.getNickname() != null) {
            sql.SET("nickname = #{nickname,jdbcType=VARCHAR}");
        }
        
        if (record.getValid() != null) {
            sql.SET("valid = #{valid,jdbcType=TINYINT}");
        }
        
        if (record.getShield() != null) {
            sql.SET("shield = #{shield,jdbcType=TINYINT}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("uid = #{uid,jdbcType=VARCHAR}");
        sql.WHERE("cid = #{cid,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}